package com.rmb.finance.controller;
import com.github.pagehelper.PageInfo;
import com.rmb.finance.service.RmbFinanceOrderService;
import com.rmb.mart.entity.linxi.RmbFinanceOrder;
import com.rmb.mart.entity.linxi.vo.Invoice;
import com.rmb.mart.entity.linxi.vo.OrderExcel;
import com.rmb.mart.entity.linxi.vo.RmbFinanceOrderVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (RmbFinanceOrder)表控制层
 *
 * @author makejava
 * @since 2021-01-23 08:44:23
 */
@RestController
@RequestMapping("rmbFinanceOrder")
public class RmbFinanceOrderController {
    /**
     * 服务对象
     */
    @Resource
    private RmbFinanceOrderService rmbFinanceOrderService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public RmbFinanceOrder selectOne(Long id) {
        return this.rmbFinanceOrderService.queryById(id);
    }

    /**
     * 查询订单
     * @param rmbFinanceOrderVo 分页数据
     * @return 列表
     */
    @PostMapping("findList")
    public PageInfo<Map<String, Object>> findList(@RequestBody RmbFinanceOrderVo rmbFinanceOrderVo){
        return rmbFinanceOrderService.findList(rmbFinanceOrderVo);
    }

    /**
     * 发票审核
     * @param page 起始
     * @param size 条数
     * @return 列表
     */
    @GetMapping("invoiceList/{page}/{size}")
    public PageInfo<Invoice> invoiceList(@PathVariable("page")int page, @PathVariable("size") int size){
        return rmbFinanceOrderService.invoiceList(page,size);
    }

    /**
     * 根据充值编号查询订单
     * @param rechargeId 编号
     * @return 列表
     */
    @GetMapping("findByOrderId/{rechargeId}")
    public List<Map<String,Object>> findByOrderId(@PathVariable("rechargeId")Long rechargeId){
        return rmbFinanceOrderService.findByOrderId(rechargeId);
    }

    /**
     * 审核订单
     * @param id 编号
     * @param checkStatus 状态
     * @return 是否
     */
    @PutMapping("updateStatus/{id}/{checkStatus}")
    public int updateStatus(@PathVariable("id")Long id,@PathVariable("checkStatus") int checkStatus){
        return rmbFinanceOrderService.updateStatus(id,checkStatus);
    }

    /**
     * 开票
     * @param id 编号
     * @param invoiceStatus invoiceStatus
     * @return 是否
     */
    @PutMapping("updInvoiceStatus/{id}/{invoiceStatus}")
    public int updInvoiceStatus(@PathVariable("id")Long id,@PathVariable("invoiceStatus")int invoiceStatus){
        return rmbFinanceOrderService.updInvoiceStatus(id,invoiceStatus);
    }

    /**
     * 到处excel
     * @return 数据
     */
    @GetMapping("export")
    public List<OrderExcel> export(){
        return rmbFinanceOrderService.export();
    }
}